﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework.Audio;
using System.Collections;

namespace Kristall.Editor
{
    public partial class PickItem : Form
    {
        public object SelectedItem
        {
            get
            {
                return itemList.SelectedItem;
            }
        }

        public PickItem(List<object> items, string displayMember = "Name")
        {
            InitializeComponent();

            itemList.DataSource = items;
            itemList.DisplayMember = displayMember;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (itemList.SelectedItem != null)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void itemList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (itemList.SelectedItem != null)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}
